package com.tbit.main.util;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;

/**
 * @author LMY
 * @create 2021-01-27 21:30
 * 数组
 */
public class ArrayUtil {

    /**
     * 判断数组中是否有重复的值
     *
     * @param array
     * @return
     */
    public static boolean cheakIsRepeat(String[] array) {
        HashSet<String> hashSet = new HashSet<String>();
        for (int i = 0; i < array.length; i++) {
            hashSet.add(array[i]);
        }
        if (hashSet.size() == array.length) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 获取两个list合并长度。
     *
     * @param listOne
     * @param listTwo
     * @return
     */
    public static Integer getIntegerByList(List listOne, List listTwo) {
        HashSet hashSet = new HashSet();
        for (int i = 0; i < listOne.size(); i++) {
            hashSet.add(listOne.get(i));
        }
        for (int i = 0; i < listTwo.size(); i++) {
            hashSet.add(listTwo.get(i));
        }
        return hashSet.size();
    }

    public static void main(String[] args) {
        List<String> one = new LinkedList<>();
        //one.add("1");
        //one.add("2");
        List<String> two = new LinkedList<>();
        two.add("2");
        two.add("3");
        one.removeAll(two);
        one.addAll(two);
        System.out.println(one);
    }
}
